import { t } from '@/locales/i18n';

import {
  FlowNodeInputTypeEnum,
  FlowNodeOutputTypeEnum,
  FlowNodeTemplateTypeEnum,
  FlowNodeTypeEnum,
  NodeInputKeyEnum,
  NodeOutputKeyEnum,
  WorkflowIOValueTypeEnum,
} from '../../constant';
import { FlowNodeTemplateType } from '../../node';
import { Input_Template_DynamicInput } from '../input';
import { getHandleConfig } from '../utils';

export const TextEditorNode: FlowNodeTemplateType = {
  id: FlowNodeTypeEnum.textEditor,
  templateType: FlowNodeTemplateTypeEnum.tools,
  flowNodeType: FlowNodeTypeEnum.textEditor,
  sourceHandle: getHandleConfig(true, true, true, true),
  targetHandle: getHandleConfig(true, true, true, true),
  avatar: 'textConcat.svg',
  name: t('text_concatenation'),
  intro: t('workflow.text_concatenation_desc'),
  courseUrl: '/docs/workflow/modules/text_editor/',
  version: '486',
  isFolded: true,
  inputs: [
    {
      ...Input_Template_DynamicInput,
      description: t('dynamic_input_description_concat'),
      customInputConfig: {
        selectValueTypeList: Object.values(WorkflowIOValueTypeEnum),
        showDescription: false,
        showDefaultValue: false,
      },
    },
    {
      key: NodeInputKeyEnum.textareaInput,
      renderTypeList: [FlowNodeInputTypeEnum.textarea],
      valueType: WorkflowIOValueTypeEnum.string,
      required: true,
      label: t('concatenation_text'),
      placeholder: '',
    },
  ],
  outputs: [
    {
      id: NodeOutputKeyEnum.text,
      key: NodeOutputKeyEnum.text,
      label: t('concatenation_result'),
      type: FlowNodeOutputTypeEnum.static,
      valueType: WorkflowIOValueTypeEnum.string,
    },
  ],
};
